home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- **
- ** Project Name: IPkg WWDC Demo
- ** File Name: IPkgIBEG.c
- **
- ** Description: IBeg routine that prepares the PKgs for the IPkg demo
- **
- ** Copyright© 1995 Aladdin Systems, inc.
- **
- *******************************************************************************
- ** A U T H O R I D E N T I T Y
- *******************************************************************************
- **
- ** Initials Name
- ** -------- -----------------------------------------------
- ** RMT Robert Thorne
- **
- *******************************************************************************
- ** R E V I S I O N H I S T O R Y
- *******************************************************************************
- **
- ** Date Time Author Description
- ** -------- ----- ------ ---------------------------------------------
- ** 05/03/95 RMT Moved scraps into MW framework
- **
- ******************************************************************************/
-
- #include "IMPackages256.h"
- #include "IPkgDemo.h"
- #include <Strings.h>
- #include "A4Globals.h" /* Quick trick to let us compile and test easier */
-
- #if !GLOBALS_ALWAYS_AVAILABLE
- #define IBEG_MAIN main
- #endif
-
- #include "IMExtensionsFor3_0.h"
-
- #define kDemoStrLen 40
-
- pascal short IBEG_MAIN (unsigned char *pw ,
- unsigned long *refCon )
- {
- long oldA4 ;
- short rslt ;
-
- // If we're running as a resource, we establish our A4 world here
- MAIN_SETUP_GLOBALS(oldA4) ;
-
- rslt = IBegMain (pw, refCon) ;
-
- MAIN_RESTORE_GLOBALS(oldA4) ;
-
- return rslt ;
-
- }
-
-
- short IBegMain ( Str255 password, unsigned long *refCon )
- {
- DialogPtr dlg ;
- Handle textH = nil ;
- unsigned long **packDataH = nil ;
- unsigned long packages [4], newPackages [4] = {0,0,0,0} ;
- Str255 packListStr ;
- char *listCPtr ;
- Rect itemRect ;
- short itemHit, itemType ;
- short i ;
-
- // Get our current package setting. Don't release this resource handle!
- packDataH = (unsigned long **) GetPackagesFromPKgs (kPKgsID, packages ) ;
-
-
- if ( !packDataH )
- return 0 ; // allow installation to procede, but bail
-
- // Construct a package string
- listCPtr = (char *) packListStr ;
-
- (void) ConstructPkgString ( packages, listCPtr, kDemoStrLen) ;
-
- c2pstr ( listCPtr ) ; // packListStr is ready to roll. Check length for
- // safety, though.
-
-
-
- //Create a dialog structure
- dlg = GetNewDialog ( kPKgsID, nil, (WindowPtr) -1 ) ;
-
- if (!dlg)
- return 1 ; // something bad; abort installation.
-
- SetPort (dlg) ;
-
- GetDItem ( dlg , iIBegStrItem , &itemType , &textH , &itemRect ) ;
-
- if (packListStr [0] != kDemoStrLen ) // check to see if we were clipped
- SetDialogItemText (textH, packListStr ) ;
-
- SelectDialogItemText ( dlg, iIBegStrItem, 0, 32767 ) ; // select all of its text
-
-
- SetDialogDefaultItem ( dlg , ok ) ;
- SetDialogCancelItem ( dlg , cancel ) ;
- SetDialogTracksCursor ( dlg , true ) ;
-
-
- //Do our modal dialog loop. We don't test for data yet.
- do
- {
- ModalDialog ( nil, &itemHit ) ;
-
- } while ( itemHit != ok && itemHit != cancel ) ;
-
- // Now process our new package string if needed
- if ( itemHit == ok )
- {
- GetIText ( textH , packListStr ) ;
-
- if (ParsePackageString ( newPackages, packListStr))
- {
- // we have a valid string, so alter data in resource handle
- for ( i=0 ; i < 4 ; i++ )
- (*packDataH)[i] = newPackages [i] ;
-
- // note that we don't call ChangedResource. This is deliberate:
- // the resource is now marked unpurgeable, so it will stay around.
- // On the other hand, we don't want the resource to get written
- // back, to allow for read-only installers.
- }
- }
-
-
- DisposDialog (dlg) ;
-
- }
-
-